<template>
	<view class="container">
		<view class="parent">
			<our-loading :active="loadingActive" text="加载中..." translateY="50" size="60" background-color="#fff1dd">
			</our-loading>
		</view>
		<swiper class="banner-swiper" circular autoplay :interval="5000" :duration="1000">
			<swiper-item class="banner-swiper-item" v-for="(item, index) in swipers" :key="index">
				<image :src="item" mode="widthFix"></image>
			</swiper-item>
		</swiper>
		<view class="content">
			<!-- section-1 begin -->
			<view class="section-1">
				<navigator class="item" open-type="switchTab" url="/pages/index/index" hover-class="none">
					<image src="https://mp-cc85421a-533b-4b68-b797-f0a3eba335d0.cdn.bspapp.com/home/home_icon_ziqu1.png"
						mode="widthFix"></image>
					<view class="wenyue-font">门店自取</view>
					<view class="text1">下单免排队</view>
				</navigator>
				<navigator class="item" open-type="navigate" url="/pages/addresses/addresses" hover-class="none">
					<image
						src="https://mp-cc85421a-533b-4b68-b797-f0a3eba335d0.cdn.bspapp.com/home/home_icon_waimai1.png"
						mode="widthFix"></image>
					<view class="wenyue-font">外卖</view>
					<view class="text1">无需接触 极速到家</view>
				</navigator>
			</view>
			<!-- section-2 end -->
			<!-- section-2 begin -->
			<view class="section-2">
				<view class="item1">
					<view class="title">
						<image
							src="https://mp-cc85421a-533b-4b68-b797-f0a3eba335d0.cdn.bspapp.com/home/home_icon_baihuo1.png">
						</image>
						<view>福利多多</view>
					</view>
					<view class="tips">优惠券 免费领取</view>
				</view>
				<navigator class="item2" open-type="navigate" url="/pages/home/group-dinner" hover-class="none">
					<view class="title">
						<image
							src="https://mp-cc85421a-533b-4b68-b797-f0a3eba335d0.cdn.bspapp.com/home/home_icon_qiye1.png">
						</image>
						<view>企业文化</view>
					</view>
					<view class="tips">立即欣赏</view>
				</navigator>
			</view>
			<!-- section-2 end -->
			<view class="section-3">
				<view class="my-integral" @tap="gotomall">
					<view style="display: flex;justify-content: center;align-items: center;">
						<view class="flowing-button">
							<!-- <view style="font-size: 28rpx;color: #676768;" v-if="!isLogin">我的积分</view> -->
							<view class="wenyue-font" style="font-size: 40rpx;color: #676768;width: 110px;">丰富的优惠券
							<view style="text-align: center;">等你来~</view>
							</view>
							<!-- <text style="font-size: 30rpx;color: #fff;font-weight: 700;">丰富的优惠券等你来~</text> -->
						</view>
					</view>
					<!-- <view style="display: flex;justify-content: center;align-items: center;">
						<view>我的积分</view>
						<view class="neutra-font">{{scores}}</view>
					</view> -->
				</view>
				<!-- <navigator class="my-code" open-type="navigate" url="/pages/my/code" hover-class="none">
					<image src="https://mp-cc85421a-533b-4b68-b797-f0a3eba335d0.cdn.bspapp.com/home/home_icon_erweima.png"></image>
					<view>会员码</view>
				</navigator> -->
			</view>
		</view>
	</view>
</template>

<script>
	import cloudApi from '../../common/cloudApi';
	import {
		mapState
	} from 'vuex'
	export default {
		data() {
			return {
				swipers: [
					"https://mp-cc85421a-533b-4b68-b797-f0a3eba335d0.cdn.bspapp.com/Swipers/6.jpg",
					"https://mp-cc85421a-533b-4b68-b797-f0a3eba335d0.cdn.bspapp.com/Swipers/5.jpg",
					"https://mp-cc85421a-533b-4b68-b797-f0a3eba335d0.cdn.bspapp.com/Swipers/1.jpg",
					"https://mp-cc85421a-533b-4b68-b797-f0a3eba335d0.cdn.bspapp.com/Swipers/2.jpg",
					"https://mp-cc85421a-533b-4b68-b797-f0a3eba335d0.cdn.bspapp.com/Swipers/3.jpg",
					"https://mp-cc85421a-533b-4b68-b797-f0a3eba335d0.cdn.bspapp.com/Swipers/4.jpg"
				],
				scores: '',
				loadingActive: true,
				coupous: []
			}
		},
		computed: {
			...mapState(['isLogin', 'userInfo'])
		},
		methods: {
			updateScores() {
				if (this.isLogin) {
					cloudApi.call({
						name: "users",
						data: {
							userId: this.userInfo.userId
						},
						success: (res) => {
							console.log(res.result[0].coupon[0].list)

							this.scores = res.result[0].score
						}
					});
				} else {
					return
				}
			},
			gotomall() {
				if (this.isLogin) {
					uni.navigateTo({
						url: '/pages/integrals/mall'
					})
				} else {
					uni.showModal({
						title: '登录提示',
						content: '请先登录哦~。'
					});
				}
			}
		},
		onShow() {
			this.updateScores();
		},
		onLoad() {
			// 在页面加载后3秒后隐藏加载组件
			setTimeout(() => {
				this.loadingActive = false;
			}, 2000);
		},
	}
</script>
<style>
	.container {
		width: 100%;
		height: 100%;
		background-color: #e6e6e6;
		position: relative;
	}

	.parent {
		width: 100vw;
		height: 100vh;
		position: absolute;
	}

	.flowing-button {
		display: flex;
		justify-content: center;
		align-items: center;
		background: linear-gradient(90deg, #cad8ff, #ffaaff, #ffa99d, #d4d7ff);
		background-size: 400%;
		width: 170px;
		height: 92px;
		border-radius: 80%;
		z-index: 1;
		animation: flow 10s infinite;
	}

	@keyframes flow {
		100% {
			background-position: -200% 0;
		}
	}
</style>

<style lang="scss" scoped>
	page {
		max-height: 100%;
	}

	.banner-swiper {
		width: 100%;
		height: 900rpx;

		.banner-swiper-item {
			image {
				width: 100%;
			}
		}
	}

	.content {
		width: 100%;

		position: relative;
	}

	.section-1 {
		position: relative;
		// background: linear-gradient(to right,#8cbeff,#a5d4ff);
		background-color: #f8f8f8;
		margin-top: -68rpx;
		border-radius: 28% 28% 0 0;
		padding: 30rpx 0;
		display: flex;
		margin-bottom: 30rpx;
		opacity: 0.8;
		box-shadow: $box-shadow;

		.item {
			flex: 1;
			flex-shrink: 0;
			display: flex;
			flex-direction: column;
			align-items: center;
			position: relative;

			&:nth-child(1):after {
				content: '';
				position: absolute;
				right: 0;
				top: 0;
				bottom: 0;
				width: 2rpx;
				background-color: $border-color;
			}

			image {
				width: 100rpx;
				margin-bottom: 20rpx;
			}

			.wenyue-font {
				font-size: 48rpx;
				margin-bottom: 10rpx;
			}

			.text1 {
				font-size: 25rpx;
				color: #676768;
			}
		}
	}

	.section-2 {
		display: flex;
		justify-content: space-between;
		// margin-bottom: 30rpx;
		padding: 0 30rpx;

		.item1,
		.item2 {
			width: 335rpx;

			padding: $spacing-row-lg 0;
			display: flex;
			flex-direction: column;
			align-items: center;
			justify-content: center;
			border-radius: 30rpx;

			.title {
				width: 100%;
				display: flex;
				align-items: center;
				justify-content: center;
				font-size: $font-size-lg;

				image {
					width: 60rpx;
					height: 60rpx;
					margin-right: 10rpx;
				}
			}

			.tips {
				color: #676768;
				font-size: $font-size-base;
			}
		}

		.item1 {
			background-image: url('https://mp-cc85421a-533b-4b68-b797-f0a3eba335d0.cdn.bspapp.com/Bg/bg3.jpg');
			background-size: cover;
		}

		.item2 {
			background-image: url('https://mp-cc85421a-533b-4b68-b797-f0a3eba335d0.cdn.bspapp.com/Bg/bg4.jpg');
			background-size: cover;
		}
	}

	.section-3 {

		margin-bottom: 30rpx;
		display: flex;
		justify-content: space-between;
		align-items: center;
		font-size: $font-size-base;
		color: $text-color-assist;
		padding: 0 10rpx;

		.my-integral {
			flex: 1;
			display: flex;
			flex-direction: column;
			padding: 0 30rpx;

			// .integrals {
			// 	display: flex;
			// 	align-items: center;
			// 	font-size: $font-size-lg;
			// 	color: $text-color-base;
			// 	margin-bottom: 10rpx;

			.neutra-font {
				margin-left: 10rpx;
				font-size: 42rpx;
			}

			// }

			.tips {
				letter-spacing: 2rpx;
			}
		}

		.my-code {
			display: flex;
			flex-direction: column;
			align-items: center;
			padding: 0 30rpx;
			position: relative;

			image {
				width: 60rpx;
				height: 60rpx;
				margin-bottom: $spacing-col-sm;
			}

			&:before {
				content: " ";
				position: absolute;
				left: 0;
				top: 0;
				bottom: 0;
				border-left: 1rpx solid rgba($color: $border-color, $alpha: 0.6);
			}
		}
	}
</style>